﻿<link rel="stylesheet" type="text/css" href="~/Content/homestyle.css"/>

<script type="text/javascript">
    $(function () {
        $("#dateresearch").datepicker($.datepicker.regional["fr"]);
    });
    var carpoolApp = angular.module('carpoolApp', []);
    carpoolApp.controller('ListWaysJson', ListWaysJson);

    /* Function Service REST*/
    function ListWaysJson($scope) {
        var list = new Array();

        $.ajax({
            url: "Way/ListLastWaysJson",
            async: false,
            type: "get",
            data: {},
            dataType: "json",
            success: function (datas) {

                for (var key in datas) {
                    var item = datas[key];
                    var dateEvent = moment(item.date).format("ddd DD MMM YYYY", "fr", true);
                    var obj = {
                        city: item.city,
                        place: item.place,
                        date: dateEvent,
                        numberPlaces: item.numberPlaces,
                        fee: item.fee
                    };

                    list.push(obj);
                }

                $scope.list = list;
            }
        });
    }
</script>
<div id="headcontent">
    <div class="middlewrapper">
        <div class="colleft">
            <div class="whitebox center">
                <span class="headtitle-pink-shadow">SEARCH</span>
                <span class="headtitle-grey-shadow">- FIND -</span>
                <span class="headtitle-pink-shadow">ENJOY</span>
                @using (Html.BeginForm("Research", "Event", FormMethod.Post))
                {
                    <input type="text" name="textresearch" placeholder="Ville / Lieu / Nom evenement"/>
                    <input id="dateresearch" type="date" name="dateresearch" placeholder="Date" maxlength="10"/>
                    <input id="submitresearch" type="image" alt="Rechercher">
                }
            </div>
				
            <div class="whitebox">
                <a href="">
                    <img src="~/Images/car.png" alt="Publier un trajet"/>
                    <span class="linktitle">publier un trajet<span>
                </a>
            </div>
				
            <div class="whitebox">
                <a href="Member/SubscriptionForm">
                    <img src="~/Images/register.png" alt="Inscription"/>
                    <span class="linktitle">inscription</span>
                    <span class="">Gratuite</span>
                </a>
            </div>
            
            <div class="whitebox">
                <a href="">
                    <img src="~/Images/organiser.png" alt="Ajouter un evenement"/>
                    <span class="linktitle">Organisateurs</span>
                    <span class="">Proposer un évènement</span>
                </a>
            </div>
        </div>
			
        <div class="colright">
            <div ng-app="carpoolApp" class="whitebox">
                <span class="titlegrand">DERNIERS COVOITURAGE</span>

                <table ng-controller="ListWaysJson">
                    <tr>
                        <th>VILLE</th>
                        <th>LIEU</th>
                        <th>DATE</th>
                        <th>PLACES DISPONIBLES</th>
                        <th>PARTICIPATION</th>
                    </tr>
                    <tr ng-repeat="way in list">
                        <td ng-bind="way.city"></td>
                        <td ng-bind="way.place"></td>
                        <td ng-bind="way.date"></td>
                        <td ng-bind="way.numberPlaces"></td>
                        <td ng-bind="way.fee"></td>
                    </tr>
                </table>
            </div>  
        </div>
    </div>
</div>